package com.zeng.sim.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.zeng.sim.controller.vo.DictDataItem;
import com.zeng.sim.mapper.SimMsgRecordMapper;
import com.zeng.sim.mapper.model.SimMsgRecordEntity;
import com.zeng.sim.service.SimMsgRecordService;
import com.zeng.sim.util.SimConstant;
import org.springframework.stereotype.Service;

import java.util.ArrayList;
import java.util.List;

/**
 * <p>
 * 服务实现类
 * </p>
 *
 * @author zengwanlin
 * @since 2023-12-26
 */
@Service
public class SimMsgRecordServiceImpl extends ServiceImpl<SimMsgRecordMapper, SimMsgRecordEntity>
        implements SimMsgRecordService {

    /**
     * 查询服务端消息编码集合
     * @return
     */
    @Override
    public List<DictDataItem> serverMsgCodeList() {
        LambdaQueryWrapper<SimMsgRecordEntity> wrapper = new LambdaQueryWrapper<>();
        wrapper.eq(SimMsgRecordEntity::getBusiType, SimConstant.BUSI_TYPE_02);
        List<SimMsgRecordEntity> msgRecordEntityList = list(wrapper);

        List<DictDataItem> list = new ArrayList<>(msgRecordEntityList.size());
        for (SimMsgRecordEntity msgRecordEntity : msgRecordEntityList) {
            DictDataItem dictDataItem = new DictDataItem();
            dictDataItem.setDataValue(msgRecordEntity.getMsgCode());
            dictDataItem.setDataLabel(msgRecordEntity.getMsgName());
            list.add(dictDataItem);
        }

        return list;
    }

}
